<%@ page language="java" import="java.util.*, com.zjut.an.user.manager.*, com.zjut.an.user.dao.*, com.zjut.an.util.tools.*,
com.zjut.zs.school.manager.*, com.zjut.zs.school.dao.*,com.zjut.an.util.system.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">  
<meta name="renderer" content="webkit"> 
<title>无标题文档</title>
<script type="text/javascript">
var browser=navigator.appName
var b_version=navigator.appVersion
var version=b_version.split(";");
var trim_Version=version[1].replace(/[ ]/g,"");
if(trim_Version=="MSIE9.0"||trim_Version=="MSIE8.0"||trim_Version=="MSIE7.0"||trim_Version=="MSIE6.0")
{
    var returnVal = window.confirm("您的浏览器版本过低或者开启了兼容模式，无法使用本系统，点击确定跳转到帮助页面查阅登录方法", "标题");
    if(returnVal) {
    	window.location.href = "../admin/soft.html";
	}else{
		window.location.href = "../admin/soft.html";
	}
}
</script>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<style type="text/css">
<!--
a {
	color: #00007f;
	text-decoration: underline;
}
-->
</style>
<%
ZsSchoolManager zsManager = (ZsSchoolManager) SpringContextUtil.getBean("ZsSchoolManager");
ZsSchool school = new ZsSchool();
school = (ZsSchool)zsManager.getDataByInstance(1,1,null,null,school).getObjects().get(0);

 %>
<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">注册</a></li>
    </ul>
    </div>
    <%if(Status.ON.getStatus().equals(school.getScRegActive())){ //如果仍然可以注册%>
    <form id="ff" name="add" role="form" class="form-horizontal" action="" method="post">  
	    <div class="formbody">    
	    <div class="formtitle"><span>账号注册</span></div>    
	    <ul class="forminfo">
	    <li><label>考生身份证号<b>*</b></label><input id="usIdcard" name="usIdcard" type="text" class="dfinput" placeholder="身份证号" required data-rule-idCard="true" data-msg-required="不能为空" data-msg-idCard="请输入身份证号" onblur="checkidcard()"/><i id="idcardlabel">请使用考生身份证登录，请仔细填写，一个考生身份证只能注册一次</i></li>
	    <li><label>密码<b>*</b></label><input id="usPassword" name="usPassword" type="password" class="dfinput" placeholder="新密码" required data-rule-psw="true" data-msg-required="不能为空" data-msg-psw="8-20位的大写字母，小写字母，数字和特殊字符4种组合" minlength="8" maxlength="20" data-msg-minlength="请输入最小8位" /><i>8-20位的大写字母，小写字母，数字和特殊字符（如@#$%）4种组合</i></li>
	    <li><label>确认密码<b>*</b></label><input id="usPassword2" name="usPassword2" type="password" class="dfinput" placeholder="确认新密码" required equalTo="#usPassword"/></li>
	    <li><label>考生真实姓名<b>*</b></label><input id="usName" name="usName" type="text" class="dfinput" placeholder="姓名" required data-rule-chinese="true" data-msg-required="不能为空" data-msg-chinese="请输入姓名"/><i>请填写考生真实姓名</i></li>
	    <li><label>邮箱<b>*</b></label><input id="usEmail" name="usEmail" type="text" class="dfinput"  placeholder="请输入email地址" required data-rule-mail="true" data-msg-required="请输入email地址" data-msg-mail="请输入正确的email地址" /><i>仔细填写，用于密码找回</i></li>
	    
	    <li><label>手机号码<b>*</b></label>
	    	<input id="usMobile" name="usMobile" type="text" class="dfinput" placeholder="手机号" required data-rule-mobile="true" data-msg-required="请输入手机号" data-msg-mobile="请输入正确格式" onkeyup="this.value=this.value.replace(/\D/g,'')" onblur="checkmobile()"/>
	    	<i id="mobilelabel">仔细填写，用于账号验证</i>
	    </li>
	    <li><label>验证码<b>*</b></label>
	    	<input type="text" id="code" name="code" class="dfinput" onblur="checkcode()" required/>
				<button type="button" id="hqyzm" class="btn btn-primary btn-sm" onclick="getcode()">
					点击获取验证码
				</button><i id="codelabel">输入手机获取到的验证码</i>
	    </li>
	    
	    <li><label>&nbsp;</label><button type="submit" class="btn btn-primary btn-sm">注册 </button>  </li>
	    <li><a href="../admin/soft.html" target='_blank'>无法注册，请点击帮助页面，</a>  忘记密码使用<a href="getpassword1.jsp">【找回密码】</a>
	    <a class="signup_link" href="http://jingyan.baidu.com/article/22a299b539f4b19e18376a5b.html" target='_blank'>360等浏览器请使用极速模式访问本系统</a>
	    </li>
	    </ul>    
	    </div>
    </form>
	<%} else {%>
    注册已经关闭。
    <%} %>
<script src="../plugins/assets/plugins/jquery-3.5.1.min.js" type="text/javascript"></script> 
<script src="../plugins/assets/plugins/jquery-validation-1.14.0/dist/jquery.validate.js" type="text/javascript"></script>
<script src="../plugins/assets/plugins/jquery-validation-1.14.0/dist/jquery.metadata.js" type="text/javascript"></script>
<script src="js/formvalidate.js" type="text/javascript"></script>
<script src="js/jquery.md5.js" type="text/javascript"></script>
<script src="../admin/js/publicManager.js" type="text/javascript" charset="utf-8"></script> 
<script type="text/javascript">

	var updateOneAction = '../zsUserAdd.action?randnum='+Math.floor(Math.random()*1000000);
	var loactionurl = 'zs_login.jsp';
	
	
	var mobilecheck=0;
	var idcardcheck=0;
	var codecheck=0;
	var code;
	function checkmobile() {
		var mobile = $("#usMobile").val();
		var label = document.getElementById("mobilelabel");
		var phone = /^1\d{10}$/;
		if (phone.test(mobile)) {
			$.ajax({
				async:false,
				cache:false,
				url: "../zsUserCount.action?usMobile=" + mobile,
				type: "GET",
				dataType: "json",
			
				success: function(data) {
					if (data.total == "0") {
						$("#mobilelabel").css("color","green");
						$("#mobilelabel").html("您的手机号码可用");
						mobilecheck=1;
					} else {
						$("#mobilelabel").css("color","red");
						$("#mobilelabel").html("手机号码已被注册，请重新输入");
						mobilecheck=0;
					}
				},
				error: function(xhr, type, errorThrown) {},
				complete: function(xhr, type, errorThrown) {}
			});
		} else {
			$("#mobilelabel").css("color","red");
			if (mobile == "") $("#mobilelabel").html("请输入手机号码");
			else $("#mobilelabel").html("请输入正确的手机号码");
		}
	}

	function checkidcard() {
		var idcard = $("#usIdcard").val();
		var label = document.getElementById("idcardlabel");
		$.ajax({
			async:false,
			cache:false,
			url: "../zsUserCount.action?usIdcard=" + idcard,
			type: "GET",
			dataType: "json",
		
			success: function(data) {
				if (data.total == "0") {
					$("#idcardlabel").css("color","green");
					$("#idcardlabel").html("您的身份证号码可用");
					idcardcheck=1;
					
				} else {
					$("#idcardlabel").css("color","red");
					$("#idcardlabel").html("身份证号码已被注册，请勿重复注册");
					idcardcheck=0;
				}
			},
			error: function(xhr, type, errorThrown) {},
			complete: function(xhr, type, errorThrown) {}
		});
	}
	
	
	function getcode() {
		//alert(idcardcheck);
		//alert((idcardcheck == 1));
		//alert((mobilecheck == 1));
		//alert((idcardcheck == 1) && (mobilecheck == 1));
		if ((idcardcheck == 1) && (mobilecheck == 1)) {
			var mobile = $("#usMobile").val();
			//alert( $("#usMobile").val());
			$.ajax({
				async:false,
				cache:false,
				url: "../sendSMS.action?usMobile=" + mobile,
				type: "GET",
				dataType: "json",
				success: function(data) {
				    //alert(data);
					//code = data.code;
					var count = 60;
					if (data.flag == "timeerror") {
						$("#codelabel").html("发送太频繁了，请稍等");
					} else if (data.flag == "success") {
						var yz = document.getElementById("hqyzm");
						yz.disabled = true;
						var timer = setInterval(function() {
							
							$("#hqyzm").html(count + "秒");
							count--;
							if (count == 0) {
								clearInterval(timer);
								$("#hqyzm").html("获取验证码");
								yz.disabled = false;
							}
						}, "1000");
					}
				},
				error: function(xhr, type, errorThrown) {},
				complete: function(xhr, type, errorThrown) {}
			});
		} else {
			checkmobile();
		}
	}

	function checkcode() {
		var temp = document.getElementById("code").value;
		var label = document.getElementById("codelabel");
		console.info(code);
		console.info(temp);
		if (temp == ""){
			$("#codelabel").css("color","red");
			$("#codelabel").html("请填写验证码");
			codecheck=0;
		} else {
			$.ajax({
				async:false,
				cache:false,
				url: "../checkCode.action?code=" + temp,
				type: "GET",
				dataType: "json",
			
				success: function(data) {
					if(data.message=="success"){
						$("#codelabel").css("color","green");
						$("#codelabel").html("验证码正确");
						codecheck=1;
						$("#usPassword").removeAttr("disabled");
						$("#usPassword2").removeAttr("disabled");
		        	} else {
		        		$("#codelabel").css("color","red");
		    			$("#codelabel").html("验证码错误");
		    			codecheck=0;
		        	}
				},
				error: function(xhr, type, errorThrown) {},
				complete: function(xhr, type, errorThrown) {}
			});
		}
	}
	
	
	$(function(){
	    //jquery.validate
	    
		$("#ff").validate({
			submitHandler: function() {
				console.info(codecheck);
				if (mobilecheck == 1 && codecheck==1 ) {
					//验证通过后 的js代码写在这里					
					submitForm();
					//submitFormOption('#ff',updateOneAction,'zs_qrcode.jsp?id='+$("#usIdcard").val());
				}				
			}
		})
	})
</script> 
</body>

</html>
